# coding: utf-8

import sys
sys.path.append('../3_data_structure')
from stack import Stack


def convert_decimal_to_binary(input_number):
    stack = Stack()

    while input_number:
        mod = input_number % 2
        input_number //= 2

        stack.push(mod)

    result = ''
    while not stack.is_empty():
        result += str(stack.pop())

    return result


print(convert_decimal_to_binary(5))
print(convert_decimal_to_binary(127))
print(convert_decimal_to_binary(1024))

# 3.26 Discussion Questions

# 手算结果：10001
print(17, convert_decimal_to_binary(17))

# 手算结果：101101
print(45, convert_decimal_to_binary(45))

# 手算过程
"""
    数字：96
    //2     %2
---------+--------
    96      0
    48      0
    24      0
    12      0
    6       0
    3       1
    1       1
    0       END
"""
print(96, convert_decimal_to_binary(96))
